import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { InfoGroupApi } from '#/api/spa/group';

import { getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'groupCode',
      label: '集团编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团编码',
      },
    },
    {
      fieldName: 'groupName',
      label: '集团名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团名称',
      },
    },
    // {
    //   fieldName: 'groupType',
    //   label: '集团类型',
    //   component: 'Select',
    //   componentProps: {
    //     options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
    //     placeholder: '请选择集团类型',
    //   },
    // },
    {
      fieldName: 'businessLicense',
      label: '营业执照号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入营业执照号',
      },
    },
    {
      fieldName: 'legalPerson',
      label: '法人代表',
      component: 'Input',
      componentProps: {
        placeholder: '请输入法人代表',
      },
    },
    {
      fieldName: 'contactPerson',
      label: '联系人',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系人',
      },
    },
    {
      fieldName: 'contactMobile',
      label: '联系电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系电话',
      },
    },
    {
      fieldName: 'contactEmail',
      label: '联系邮箱',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系邮箱',
      },
    },
    {
      fieldName: 'address',
      label: '集团地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团地址',
      },
    },
    {
      fieldName: 'website',
      label: '官网地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入官网地址',
      },
    },
    {
      fieldName: 'logoUrl',
      label: 'Logo地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入Logo地址',
      },
    },
    {
      fieldName: 'description',
      label: '集团描述',
      component: 'RichTextarea',
    },
    {
      fieldName: 'status',
      label: '状态',
      // component: 'RadioGroup',
      // componentProps: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   buttonStyle: 'solid',
      //   optionType: 'button',
      // },
    },
    // {
    //   fieldName: 'parentGroupId',
    //   label: '父集团ID',
    //   component: 'Input',
    //   componentProps: {
    //     placeholder: '请输入父集团ID',
    //   },
    // },
    // {
    //   fieldName: 'level',
    //   label: '层级',
    //   component: 'Input',
    //   componentProps: {
    //     placeholder: '请输入层级',
    //   },
    // },
    {
      fieldName: 'sortOrder',
      label: '排序',
      component: 'Input',
      componentProps: {
        placeholder: '请输入排序',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'groupCode',
      label: '集团编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团编码',
      },
    },
    {
      fieldName: 'groupName',
      label: '集团名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团名称',
      },
    },
    // {
    //   fieldName: 'groupType',
    //   label: '集团类型',
    //   component: 'Select',
    //   componentProps: {
    //     allowClear: true,
    //     options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
    //     placeholder: '请选择集团类型',
    //   },
    // },
    {
      fieldName: 'businessLicense',
      label: '营业执照号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入营业执照号',
      },
    },
    {
      fieldName: 'legalPerson',
      label: '法人代表',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入法人代表',
      },
    },
    {
      fieldName: 'contactPerson',
      label: '联系人',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入联系人',
      },
    },
    {
      fieldName: 'contactMobile',
      label: '联系电话',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入联系电话',
      },
    },
    {
      fieldName: 'contactEmail',
      label: '联系邮箱',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入联系邮箱',
      },
    },
    {
      fieldName: 'address',
      label: '集团地址',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团地址',
      },
    },
    {
      fieldName: 'website',
      label: '官网地址',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入官网地址',
      },
    },
    // {
    //   fieldName: 'logoUrl',
    //   label: 'Logo地址',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入Logo地址',
    //   },
    // },
    // {
    //   fieldName: 'description',
    //   label: '集团描述',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入集团描述',
    //   },
    // },
    {
      fieldName: 'status',
      label: '状态',
      // component: 'Select',
      // componentProps: {
      //   allowClear: true,
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'string'),
      //   placeholder: '请选择状态',
      // },
    },
    // {
    //   fieldName: 'parentGroupId',
    //   label: '父集团ID',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入父集团ID',
    //   },
    // },
    // {
    //   fieldName: 'level',
    //   label: '层级',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入层级',
    //   },
    // },
    // {
    //   fieldName: 'sortOrder',
    //   label: '排序',
    //   component: 'Input',
    //   componentProps: {
    //     allowClear: true,
    //     placeholder: '请输入排序',
    //   },
    // },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<InfoGroupApi.InfoGroup>['columns'] {
  return [
    // {
    //   field: 'id',
    //   title: '主键ID',
    //   minWidth: 120,
    // },
    {
      field: 'groupCode',
      title: '集团编码',
      minWidth: 120,
    },
    {
      field: 'groupName',
      title: '集团名称',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_SPA_TYPE.HandCardStatus },
      // },
    },
    // {
    //   field: 'groupType',
    //   title: '集团类型',
    //   minWidth: 120,
    //   cellRender: {
    //     name: 'CellDict',
    //     props: { type: DICT_SPA_TYPE.HandCardStatus },
    //   },
    // },
    {
      field: 'businessLicense',
      title: '营业执照号',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_SPA_TYPE.HandCardStatus },
      // },
    },
    {
      field: 'legalPerson',
      title: '法人代表',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_SPA_TYPE.HandCardStatus },
      // },
    },
    {
      field: 'contactPerson',
      title: '联系人',
      minWidth: 120,
    },
    {
      field: 'contactMobile',
      title: '联系电话',
      minWidth: 120,
    },
    {
      field: 'contactEmail',
      title: '联系邮箱',
      minWidth: 120,
    },
    {
      field: 'address',
      title: '集团地址',
      minWidth: 120,
    },
    {
      field: 'website',
      title: '官网地址',
      minWidth: 120,
    },
    {
      field: 'logoUrl',
      title: 'Logo地址',
      minWidth: 120,
    },
    {
      field: 'description',
      title: '集团描述',
      minWidth: 120,
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_SPA_TYPE.HandCardStatus },
      // },
    },
    {
      field: 'sortOrder',
      title: '排序',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

// ==================== 子表（门店） ====================

/** 新增/修改列表的字段 */
export function useInfoStoreGridEditColumns(): VxeTableGridOptions<InfoGroupApi.InfoStore>['columns'] {
  return [
    {
      field: 'storeCode',
      title: '门店编码',
      minWidth: 120,
      slots: { default: 'storeCode' },
    },
    {
      field: 'storeName',
      title: '门店名称',
      minWidth: 120,
      slots: { default: 'storeName' },
    },
    {
      field: 'parentStoreId',
      title: '父门店ID',
      minWidth: 120,
      slots: { default: 'parentStoreId' },
    },
    {
      field: 'storeType',
      title: '门店类型',
      minWidth: 120,
      // slots: { default: 'storeType' },
      // params: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'number'),
      // },
    },
    {
      field: 'contactPerson',
      title: '联系人',
      minWidth: 120,
      slots: { default: 'contactPerson' },
    },
    {
      field: 'contactPhone',
      title: '联系电话',
      minWidth: 120,
      slots: { default: 'contactPhone' },
    },
    {
      field: 'contactEmail',
      title: '联系邮箱',
      minWidth: 120,
      slots: { default: 'contactEmail' },
    },
    {
      field: 'address',
      title: '地址',
      minWidth: 120,
      slots: { default: 'address' },
    },
    {
      field: 'longitude',
      title: '经度',
      minWidth: 120,
      slots: { default: 'longitude' },
    },
    {
      field: 'latitude',
      title: '纬度',
      minWidth: 120,
      slots: { default: 'latitude' },
    },
    {
      field: 'businessHours',
      title: '营业时间',
      minWidth: 120,
      slots: { default: 'businessHours' },
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
      // slots: { default: 'status' },
      // params: {
      //   options: getDictOptions(DICT_SPA_TYPE.HandCardStatus, 'number'),
      // },
    },
    {
      field: 'openTime',
      title: '开业时间',
      minWidth: 120,
      slots: { default: 'openTime' },
    },
    {
      field: 'config',
      title: '门店配置',
      minWidth: 120,
      slots: { default: 'config' },
    },
    {
      field: 'iotConfig',
      title: 'IoT设备配置',
      minWidth: 120,
      slots: { default: 'iotConfig' },
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
      slots: { default: 'orgId' },
    },
    {
      field: 'businessLicense',
      title: '营业执照号',
      minWidth: 120,
      slots: { default: 'businessLicense' },
    },
    {
      field: 'storeManager',
      title: '店长',
      minWidth: 120,
      slots: { default: 'storeManager' },
    },
    {
      field: 'city',
      title: '城市',
      minWidth: 120,
      slots: { default: 'city' },
    },
    {
      field: 'district',
      title: '区县',
      minWidth: 120,
      slots: { default: 'district' },
    },
    {
      field: 'handCardCount',
      title: '手牌数量',
      minWidth: 120,
      slots: { default: 'handCardCount' },
    },
    {
      field: 'roomCount',
      title: '房间数量',
      minWidth: 120,
      slots: { default: 'roomCount' },
    },
    {
      field: 'technicianCount',
      title: '技师数量',
      minWidth: 120,
      slots: { default: 'technicianCount' },
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
